from rest_framework import serializers

from recruit.models import Recruit, Enterprise
from users.models import User


class EnterpriseSerializer(serializers.ModelSerializer):
    """企业信息"""

    class Meta:
        model = Enterprise
        fields = '__all__'


# 推荐职位
class RecruitsSearchRecommendSerializer(serializers.ModelSerializer):
    enterprise = EnterpriseSerializer()

    class Meta:
        model = Recruit
        fields = '__all__'


# 搜索职位
class RecruitsSearchCityKeywordSerializer(serializers.ModelSerializer):
    enterprise = EnterpriseSerializer()

    class Meta:
        model = Recruit
        fields = '__all__'


# 职位
class RecruitsSerializer(serializers.ModelSerializer):
    enterprise = EnterpriseSerializer()

    class Meta:
        model = Recruit
        fields = '__all__'


# 用户
class UserSerializer(serializers.ModelSerializer):
    class Meta:
        model = User
        fields = '__all__'


# 企业
class EnterpriseRecruitsSerializer(serializers.ModelSerializer):
    recruits = RecruitsSerializer(many=True)
    users = UserSerializer(many=True)

    class Meta:
        model = Enterprise
        fields = '__all__'


# 详情
class RecruitsIdSerializer(serializers.ModelSerializer):
    enterprise = EnterpriseRecruitsSerializer()

    class Meta:
        model = Recruit
        fields = '__all__'
